# -------------------------------------------------------------------
#       -*- coding: utf-8 -*-
#   @Project    :   spider
#   @File       :   43_线程池和进程池.py
#   @Author     :   WANGYU
#   @Time       :   2021-08-27 10:30:35
#   @Software   :   PyCharm
#   @Desc       :   
# -------------------------------------------------------------------


# 线程池：一次性开辟一些线程，我们用户直接给线程池提交任务，线程任务到调度交给线程池来完成
from concurrent.futures import ThreadPoolExecutor, ProcessPoolE,xecutor  # 线程池，进程池


def fn(name):
    for i in range(100):
        print(name, i)


if __name__ == '__main__':
    # 创建线程池50个
    with ThreadPoolExecutor(50) as t:
        for i in range(100):
            t.submit(fn, name=f'线程{i}')
            # 等待线程池中到任务全部执行完毕，才继续执行（守护）
    print('------------------over-------------------')
